<?php
declare(strict_types=1);

use Phinx\Migration\AbstractMigration;

final class CreateMessageTaskConfirmTable extends AbstractMigration
{
    public function up()
    {
        $table = $this->table('message_task_confirm', ['id' => false, 'primary_key' => ['id'], 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '任务是否确认表']);
        $table->addColumn('id', 'integer', ['identity' => true, 'signed' => false, 'limit' => 11, 'comment' => '自增id'])
            ->addColumn('link_id', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '关联id'])
            ->addColumn('link_module_code', 'char', ['default' => '', 'limit' => 128, 'comment' => '关联类型'])
            ->addColumn('link_step_category', 'char', ['default' => '', 'limit' => 128, 'comment' => '关联环节'])
            ->addColumn('confirm', 'char', ['default' => 'default', 'limit' => 36, 'comment' => '是否确认'])
            ->addColumn('confirm_user_id', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '确认人用户id'])
            ->addColumn('source_type', 'char', ['default' => '', 'limit' => 36, 'comment' => '来源类型:关联修改(relation_change)、返修(repair)、废除(deprecated)、任务发布(version_publish)'])
            ->addColumn('remark', 'char', ['default' => '', 'limit' => 200, 'comment' => '备注'])
            ->addColumn('project_id', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '项目ID'])
            ->addColumn('tenant_id', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '租户ID'])
            ->addColumn('created_by', 'integer', ['signed' => false, 'limit' => 11, 'default' => 0, 'comment' => '创建人'])
            ->addColumn('created', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '创建时间'])
            ->addIndex(['link_id'], ['type' => 'normal', 'name' => 'idx_link_id'])
            ->addIndex(['confirm_user_id'], ['type' => 'normal', 'name' => 'idx_confirm_user_id'])
            ->addIndex(['project_id'], ['type' => 'normal', 'name' => 'idx_project_id'])
            ->save();
    }

    public function down()
    {
        $this->table('message_task_confirm')->drop()->save();
    }
}
